package com.foxzzz.deep.first;

import com.foxzzz.base.TreeNode;

import java.util.List;

/**
 * @author: [wujie]
 * @createTime: [2019/12/11 17:44]
 * @description:
 */
public class Solution101 {



    public boolean isSymmetric(TreeNode root) {
        return treeEquals(root, root);
    }

    public boolean treeEquals(TreeNode t1, TreeNode t2) {
        if (t1 == null && t2 == null) {
            return true;
        } else if (t1 == null || t2 == null) {
            return false;
        }

        return  t1.val==t2.val&&treeEquals(t1.left, t2.right) && treeEquals(t1.right, t2.left);
    }


    public static void main(String[] args) {
        TreeNode treeNode = TreeNode.getTreeNode("[1,2,3]");
        System.out.println(new Solution101().isSymmetric(treeNode));
    }
}
